import Mock from "mockjs";
import city from "./index.json";
import { tab } from "./tab.js";
import dateJson from "./data.json";
Mock.mock(RegExp("/getCity" + ".*"), (req, res) => {
  const type = req.url.split("=")[1];
  tab(city, 1);
  switch (type) {
    case "day":
      return {
        list: tab(city, 1),
        background: "#559EFD",
      };

    case "week":
      return {
        list: tab(city, 7),
        background: "#FFA315",
      };
    case "month":
      return {
        list: tab(city, 8),
        background: "#F1749F",
      };
    default:
      break;
  }
});
Mock.mock("/api/trips", {
  "list|20": [
    {
      "id|+1": 1,
      trips: "G71高铁",
      name: "@cname",
      "sum|100-900": 0,
      "count|1-10": 0,
      "total|500-900": 0,
      startStation: "北京西-昆明南",
      lines:
        "① 北京西 → ② 石家庄 → ③ 郑州东 →  ④ 武汉 → ⑤ 长沙南 →  ⑥怀化南 → ⑦贵阳北 → ⑧ 昆明南",
      create_time: "@now()",
      "state|1": [true, false],
    },
  ],
});
Mock.mock("/api/city", {
  "list|20": [
    {
      "id|+1": 1,
      city: "@city",
      "state|1": [true, false],
    },
  ],
});
Mock.mock(RegExp("/api/search" + ".*"), (req) => {
  const ipt = req.url.split("&")[0].split("=")[1];
  const date = req.url.split("date=")[1];
  return dateJson.filter((item) => item.idCard === ipt && item.date === date);
});
Mock.mock("/api/tickets", {
  "list|20": [
    {
      "id|+1": 1,
      "trips|+1": ["G71高铁", "Z49动车", "T145特快"],
      dateTime: "2023-4-03",
      name: "@cname",
      "sum|100-900": 0,
      "total|500-900": 0,
      "startTime|+1": [
        "7:5",
        "11:28",
        "14:16",
        "17:18",
        "7:5",
        "11:28",
        "14:16",
        "17:18",
        "14:16",
        "17:18",
      ],
      "endTime|+1": [
        "17:29",
        "8:28",
        "7:25",
        "11:48",
        "17:29",
        "8:28",
        "7:25",
        "11:48",
        "7:25",
        "11:48",
      ],
      "startStation|+1": [
        "北京西-昆明南",
        "北京西—成都东",
        "北京西-南昌",
        "包头-广州",
      ],
      "seat|+1": ["软卧", "硬卧", "硬座", "无座", "商务座", "一等座", "二等座"],
      "seatType|+1": ["0", "0", "0", "0", "60", "128", "220"],
      "last|+1": ["10:24", "21:00", "17:09", "40:30"],
      "arrive|+1": ["当日到达", "次日到达", "次日到达", "三日后到达"],
      "status|+1": ["已提交", "未提交", "已提交", "已提交", "已提交", "未提交"],
      create_time: "@dateTime",
      "state|1": [true, false],
    },
  ],
});
Mock.mock("/api/order", {
  list: [
    {
      orderInfo: {
        orderId: "E123456",
        name: "张三三",
        phoneNumber: "1881234600",
        dateTime: "2022-10-10 12:20:39",
      },
      trainType: {
        train: "G71",
        type: "高铁",
      },
      station: {
        startStation: "北京西",
        endStation: "武汉",
      },
      time: {
        startTime: "07:05",
        endTime: "11:01",
      },
      date: "2022-10-10",
      seatInfo: {
        price: 120,
        carriage: "02",
        seat: "09A",
        seatType: 1,
      },
      state: 1,
    },
    {
      orderInfo: {
        orderId: "E123456",
        name: "刘能能",
        phoneNumber: "1881234600",
        dateTime: "2022-10-10 12:20:39",
      },
      trainType: {
        train: "T316",
        type: "火车",
      },
      station: {
        startStation: "北京西",
        endStation: "武汉",
      },
      time: {
        startTime: "07:05",
        endTime: "11:01",
      },
      date: "2022-10-10",
      seatInfo: {
        price: 120,
        carriage: "02",
        seat: "09A",
        seatType: 2,
      },
      state: 2,
    },
    {
      orderInfo: {
        orderId: "E123456",
        name: "张三三",
        phoneNumber: "1881234600",
        dateTime: "2022-10-10 12:20:39",
      },
      trainType: {
        train: "G71",
        type: "高铁",
      },
      station: {
        startStation: "北京西",
        endStation: "武汉",
      },
      time: {
        startTime: "07:05",
        endTime: "11:01",
      },
      date: "2022-10-10",
      seatInfo: {
        price: 120,
        carriage: "02",
        seat: "09A",
        seatType: 1,
      },
      state: 3,
    },
    {
      orderInfo: {
        orderId: "E123456",
        name: "张三三",
        phoneNumber: "1881234600",
        dateTime: "2022-10-10 12:20:39",
      },
      trainType: {
        train: "G71",
        type: "高铁",
      },
      station: {
        startStation: "北京西",
        endStation: "武汉",
      },
      time: {
        startTime: "07:05",
        endTime: "11:01",
      },
      date: "2022-10-10",
      seatInfo: {
        price: 120,
        carriage: "02",
        seat: "09A",
        seatType: 1,
      },
      state: 1,
    },
    {
      orderInfo: {
        orderId: "E123456",
        name: "刘能能",
        phoneNumber: "1881234600",
        dateTime: "2022-10-10 12:20:39",
      },
      trainType: {
        train: "T316",
        type: "火车",
      },
      station: {
        startStation: "北京西",
        endStation: "武汉",
      },
      time: {
        startTime: "07:05",
        endTime: "11:01",
      },
      date: "2022-10-10",
      seatInfo: {
        price: 120,
        carriage: "02",
        seat: "09A",
        seatType: 2,
      },
      state: 2,
    },
    {
      orderInfo: {
        orderId: "E123456",
        name: "张三三",
        phoneNumber: "1881234600",
        dateTime: "2022-10-10 12:20:39",
      },
      trainType: {
        train: "G71",
        type: "高铁",
      },
      station: {
        startStation: "北京西",
        endStation: "武汉",
      },
      time: {
        startTime: "07:05",
        endTime: "11:01",
      },
      date: "2022-10-10",
      seatInfo: {
        price: 120,
        carriage: "02",
        seat: "09A",
        seatType: 1,
      },
      state: 3,
    },
    {
      orderInfo: {
        orderId: "E123456",
        name: "张三三",
        phoneNumber: "1881234600",
        dateTime: "2022-10-10 12:20:39",
      },
      trainType: {
        train: "G71",
        type: "高铁",
      },
      station: {
        startStation: "北京西",
        endStation: "武汉",
      },
      time: {
        startTime: "07:05",
        endTime: "11:01",
      },
      date: "2022-10-10",
      seatInfo: {
        price: 120,
        carriage: "02",
        seat: "09A",
        seatType: 1,
      },
      state: 1,
    },
    {
      orderInfo: {
        orderId: "E123456",
        name: "刘能能",
        phoneNumber: "1881234600",
        dateTime: "2022-10-10 12:20:39",
      },
      trainType: {
        train: "T316",
        type: "火车",
      },
      station: {
        startStation: "北京西",
        endStation: "武汉",
      },
      time: {
        startTime: "07:05",
        endTime: "11:01",
      },
      date: "2022-10-10",
      seatInfo: {
        price: 120,
        carriage: "02",
        seat: "09A",
        seatType: 2,
      },
      state: 2,
    },
    {
      orderInfo: {
        orderId: "E123456",
        name: "张三三",
        phoneNumber: "1881234600",
        dateTime: "2022-10-10 12:20:39",
      },
      trainType: {
        train: "G71",
        type: "高铁",
      },
      station: {
        startStation: "北京西",
        endStation: "武汉",
      },
      time: {
        startTime: "07:05",
        endTime: "11:01",
      },
      date: "2022-10-10",
      seatInfo: {
        price: 120,
        carriage: "02",
        seat: "09A",
        seatType: 1,
      },
      state: 3,
    },
  ],
});
